<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Craftsman
 *
 * @property int $teams_id 工种
 * @mixin \Eloquent
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Skill[] $skill
 * @property-read \App\Team $teams
 * @property int $id
 * @property string $name 班组名称
 * @property int $level 星级
 * @property int $mens 人数
 * @property int $team_id 工种
 * @property \Carbon\Carbon|null $created_at
 * @property \Carbon\Carbon|null $updated_at
 * @property int|null $header_id 班组长ID
 * @property-read \App\Member|null $header
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Craftsman whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Craftsman whereHeaderId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Craftsman whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Craftsman whereLevel($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Craftsman whereMens($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Craftsman whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Craftsman whereTeamId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Craftsman whereUpdatedAt($value)
 * @property int|null $project_id
 * @property array $images
 * @property string|null $lng
 * @property string|null $lat
 * @property-read \App\Project|null $project
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Craftsman whereImages($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Craftsman whereLat($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Craftsman whereLng($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Craftsman whereProjectId($value)
 */
class Craftsman extends Model
{
    protected $casts = [
        'images' => 'array'
    ];
    public function teams()
    {
        return $this->belongsTo('App\Team','team_id','id');
    }
    public function header(){
        return $this->belongsTo('App\Member','header_id','id');
    }

    public function project(){
        return $this->belongsTo('App\Project');
    }

    public function members()
    {
        return $this->hasMany('App\Member','craftmans','id');
    }

    public function items()
    {
        return $this->hasMany('App\Item','craftmans_id','id');
    }
    protected $guarded = [];
}
